package com.agileboot.domain.feedback.vo;

import com.agileboot.domain.feedback.db.UserFeedback;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Date;

@Data
@ApiModel(value = "UserFeedbackVO对象", description = "用户认证信息表")
public class UserFeedbackVO {
    /**
     * 意见反馈id
     */
    @ApiModelProperty("意见反馈id")
    @JsonSerialize(using = ToStringSerializer.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long id;
    /**
     * 用户手机号
     */
    @ApiModelProperty("用户phone")
    private String phone;
    /**
     * 用户标识
     */
    @ApiModelProperty("用户id")
    private Long userId;

    /**
     * 用户名
     */
    @ApiModelProperty("用户名")
    private String userName;

    /**
     * 反馈内容
     */
    @ApiModelProperty("反馈内容")
    private String content;

    /**
     * 图片地址，','分隔
     */
    @ApiModelProperty("图片地址")
    private String imgUrls;

    /**
     * 0为未回复，1已回复
     */
    @ApiModelProperty("0为未回复，1已回复")
    private Integer status;

    /**
     * 处理时间
     */
    @ApiModelProperty("处理时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime handleTime;

    /**
     * 处理内容
     */
    @ApiModelProperty("处理内容")
    private String handleContent;

    /**
     * 处理结果图片
     */
    @ApiModelProperty("处理结果图片")
    private String handleImg;

    private Date createTime;


    public static UserFeedbackVO of (UserFeedback userFeedback) {
        if (userFeedback == null) {
            return null;
        }
        UserFeedbackVO res = new UserFeedbackVO();
        res.setId(userFeedback.getId());
        res.setUserId(userFeedback.getUserId());
        res.setUserName(userFeedback.getUserName());
        res.setContent(userFeedback.getContent());
        res.setImgUrls(userFeedback.getImgUrls());
        res.setCreateTime(userFeedback.getCreateTime());

        res.setHandleContent(userFeedback.getHandleContent());
        res.setHandleTime(userFeedback.getHandleTime());
        res.setHandleImg(userFeedback.getHandleImg());
        res.setStatus(userFeedback.getStatus());
        return res;
    }

}
